package hjt.com.module_test.activity;

import android.os.Bundle;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.ItemTouchHelper;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.tong.lib.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import hjt.com.componentbase.constant.ARouterConstants;
import hjt.com.module_test.R;
import hjt.com.module_test.R2;
import hjt.com.module_test.adpter.TestAdpter;
import hjt.com.module_test.widget.RlvItemTouchHelper;

@Route(path = ARouterConstants.ACTIVITY_TEST_DRAG)
public class DragActivity extends BaseActivity {

    @BindView(R2.id.rlv)
    RecyclerView rlv;
    private List<String> dataList = new ArrayList<>();

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_drag;
    }

    @Override
    protected void init(Bundle savedInstanceState) {
        for (int i = 0; i < 10; i++) {
            dataList.add("test" + i);
        }
        rlv.setLayoutManager(new GridLayoutManager(getContext(), 2));
        TestAdpter testAdpter = new TestAdpter(getContext(), dataList);
        rlv.setAdapter(testAdpter);
        ItemTouchHelper.Callback callback = new RlvItemTouchHelper(testAdpter);
        ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
        itemTouchHelper.attachToRecyclerView(rlv);
    }

    @Override
    protected void initEvent() {

    }

}
